home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group01a.txt
/
000071_icon-group-sender _Tue Jun 27 16:58:58 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2002-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id QAA21141
for icon-group-addresses; Tue, 27 Jun 2000 16:58:51 -0700 (MST)
Message-Id: <200006272358.QAA21141@baskerville.CS.Arizona.EDU>
To: Gregg Townsend <gmt@baskerville.CS.Arizona.EDU>
cc: Steve_Graham@labcorp.com, icon-group@optima.CS.Arizona.EDU,
wgg@cs.ucsd.edu
Subject: Re: Permutations/Combinations
Date: Tue, 27 Jun 2000 13:28:05 -0700
From: William Griswold <wgg@cs.ucsd.edu>
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Content-Length: 1705
Or you can turn it around and generate all possible 6 letter permutations
and run the results through a spell checker. 6 factorial isn't that bad. :)
A small catch is that spell checkers tell you what is bad, rather than good,
and some make mistakes and let stuff through.
procedure main(args)
every write(genstrings(cset(args[1])))
end
procedure genstrings(chars)
if *chars = 1 then return chars
every c := !chars do
suspend (c || genstrings(chars -- c))
end
Here is a Unix shell script that completes the job:
#!/bin/csh
set tmp = /tmp/tmp$$
permute $1 > $tmp.perm
spell $tmp.perm > $tmp.misp
cat $tmp.misp $tmp.perm | sort | uniq -u
rm -f $tmp.perm $tmp.misp
--bill
In msg <200006271949.MAA14033@baskerville.CS.Arizona.EDU>, Gregg Townsend says:
> From: "Steve Graham" <Steve_Graham@labcorp.com>
>
> We have a brain teaser floating around work whose object is to find all
> 6-letter English words which can be made from the letters A, E, R, B,M
> and L. I'm sure you can do this with Icon's reversible assignment,
> but I don't understand the latter. Can anyone help me?
>
>If you have a list of English words, an easy solution to the brain teaser
>is to run the list through this filter:
>
> procedure main()
> local word
> while word := read() do
> if *word = 6 & cset(map(word)) == 'aerbml' then
> write(word)
> end
>
>Of course, I have managed to avoid entirely your question about
>reversible assignment.
>
> ---------------------------------------------------------------------------
> Gregg Townsend Staff Scientist The University of Arizona
> gmt@cs.arizona.edu Computer Science Tucson, Arizona, USA
>
>